package com.omi.iberolactalpreventa.objects;

import java.util.ArrayList;
import com.omi.iberolactalpreventa.R;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class AdapterPedido extends BaseAdapter{

	Activity activity;
	ArrayList<ItmPedido> items;
	
	
	
	public AdapterPedido(Activity activity, ArrayList<ItmPedido> items) {
		this.activity = activity;
		this.items = items;
	}

	@Override
	public int getCount() {
		return items.size();
	}

	@Override
	public Object getItem(int position) {
		return items.get(position);
	}

	@Override
	public long getItemId(int position) {
		return items.get(position).getId();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View v = convertView;
		
		if(convertView==null)
		{
			LayoutInflater inf =(LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			v = inf.inflate(R.layout.item_pedido, null);
		}
		
		ItmPedido p = items.get(position);
		TextView lblFechaPed = (TextView) v.findViewById(R.id.lblFechaPed);
		lblFechaPed.setText(p.getFecha());
		TextView lblNumPed = (TextView) v.findViewById(R.id.lblNumPed);
		lblNumPed.setText(p.getNumPedido());
		TextView lblRefUm = (TextView) v.findViewById(R.id.lblRefUm);
		lblRefUm.setText(p.getReferencia());
		
		return v;
	}

}
